package com.solidumgame.martillo.nail
{
	import com.pblabs.engine.PBE;
	import com.pblabs.engine.entity.EntityComponent;
	import com.solidumgame.martillo.nail.events.NailGenericEvent;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.media.Sound;
	import flash.net.URLRequest;
	
	public class NailSoundComponent extends EntityComponent
	{
		
		public var url:URLRequest;
		public var soundNail:Sound;
		
		public function NailSoundComponent()
		{
			
		}
		
		override protected function onAdd():void{
			super.onAdd();
			owner.eventDispatcher.addEventListener(NailGenericEvent.NAIL_FLOOR_HIT_EVENT,nailHitSound);
		}
		
		public function nailHitSound(e:NailGenericEvent):void{
			url = new URLRequest("../assets/sounds/clavo.mp3");
			soundNail = new Sound(url);
			soundNail.play(0,0);
		}
	}
}